final class SceneGraph {
	private static boolean aBoolean467;
	private static boolean[][] aBooleanArrayArray492;
	private static boolean[][][][] aBooleanArrayArrayArrayArray491 = new boolean[8][32][51][51];
	private static Deque aClass19_477 = new Deque();
	private static InteractiveObject[] aClass28Array462 = new InteractiveObject[100];
	private static final CullingCluster[] aClass47Array476 = new CullingCluster[500];
	private static CullingCluster[][] aClass47ArrayArray474;
	private static int anInt446;
	private static int anInt447;
	private static int anInt448;
	private static int anInt449;
	private static int anInt450;
	private static int anInt451;
	private static int anInt452;
	private static int anInt453;
	private static int anInt454;
	private static int anInt455;
	private static int anInt456;
	private static int anInt457;
	private static int sinePitch;
	private static int cosinePitch;
	private static int sineYaw;
	private static int cosineYaw;
	private static int anInt468;
	private static int anInt469;
	public static int anInt470 = -1;
	public static int anInt471 = -1;
	private static final int anInt472;
	private static int anInt475;
	private static int anInt493;
	private static int anInt494;
	private static int anInt495;
	private static int anInt496;
	private static int anInt497;
	private static int anInt498;
	private static final int[] anIntArray463 = { 53, -53, -53, 53 };
	private static final int[] anIntArray464 = { -53, -53, 53, 53 };
	private static final int[] anIntArray465 = { -45, 45, 45, -45 };
	private static final int[] anIntArray466 = { 45, 45, -45, -45 };
	private static int[] anIntArray473;
	private static final int[] anIntArray478 = { 19, 55, 38, 155, 255, 110, 137, 205, 76 };
	private static final int[] anIntArray479 = { 160, 192, 80, 96, 0, 144, 80, 48, 160 };
	private static final int[] anIntArray480 = { 76, 8, 137, 4, 0, 1, 38, 2, 19 };
	private static final int[] anIntArray481 = { 0, 0, 2, 0, 0, 2, 1, 1, 0 };
	private static final int[] anIntArray482 = { 2, 0, 0, 2, 0, 0, 0, 4, 4 };
	private static final int[] anIntArray483 = { 0, 4, 4, 8, 0, 0, 8, 0, 0 };
	private static final int[] anIntArray484 = { 1, 1, 0, 0, 0, 8, 0, 0, 8 };
	private static final int[] anIntArray485 = { 41, 39248, 41, 4643, 41, 41, 41, 41, 41, 41, 41,
	41, 41, 41, 41, 43086, 41, 41, 41, 41, 41, 41, 41, 8602, 41, 28992, 41, 41, 41, 41, 41, 5056,
	41, 41, 41, 7079, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 3131, 41, 41, 41 };
	public static boolean lowMem = true;
	private boolean aBoolean434;
	private final int anInt437;
	private final int anInt438;
	private final int anInt439;
	private int anInt442;
	private int anInt488;
	private final int[] anIntArray486;
	private final int[] anIntArray487;
	private final int[][] anIntArrayArray489 = { new int[16],
	{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
	{ 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1 },
	{ 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 },
	{ 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1 },
	{ 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
	{ 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 },
	{ 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0 },
	{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0 },
	{ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1 },
	{ 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 },
	{ 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1 },
	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1 } };
	private final int[][] anIntArrayArray490 = {
	{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
	{ 12, 8, 4, 0, 13, 9, 5, 1, 14, 10, 6, 2, 15, 11, 7, 3 },
	{ 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
	{ 3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12 } };
	private final int[][][] anIntArrayArrayArray440;
	private final int[][][] anIntArrayArrayArray445;
	private final Tile[][][] groundArray;
	private final InteractiveObject[] actions;
	private int interactiveObjectActions;
	static {
		anInt472 = 4;
		SceneGraph.anIntArray473 = new int[SceneGraph.anInt472];
		SceneGraph.aClass47ArrayArray474 = new CullingCluster[SceneGraph.anInt472][500];
	}

	public static void method277(int i, int j, int k, int l, int i1, int j1, int l1, int i2) {
		CullingCluster cullingCluster = new CullingCluster();
		cullingCluster.tileStartX = j / 128;
		cullingCluster.tileEndX = l / 128;
		cullingCluster.tileStartY = l1 / 128;
		cullingCluster.tileEndY = i1 / 128;
		cullingCluster.searchMask = i2;
		cullingCluster.worldStartX = j;
		cullingCluster.worldEndX = l;
		cullingCluster.worldStartY = l1;
		cullingCluster.worldEndY = i1;
		cullingCluster.worldStartZ = j1;
		cullingCluster.worldEndZ = k;
		SceneGraph.aClass47ArrayArray474[i][SceneGraph.anIntArray473[i]++] = cullingCluster;
	}

	public static void init(int i, int j, int width, int height, int pixels[]) {
		SceneGraph.anInt495 = 0;
		SceneGraph.anInt496 = 0;
		SceneGraph.anInt497 = width;
		SceneGraph.anInt498 = height;
		SceneGraph.anInt493 = width / 2;
		SceneGraph.anInt494 = height / 2;
		boolean aflag[][][][] = new boolean[9][32][53][53];
		for (int i1 = 128; i1 <= 384; i1 += 32) {
			for (int j1 = 0; j1 < 2048; j1 += 64) {
				SceneGraph.sinePitch = Model.sineTable[i1];
				SceneGraph.cosinePitch = Model.cosineTable[i1];
				SceneGraph.sineYaw = Model.sineTable[j1];
				SceneGraph.cosineYaw = Model.cosineTable[j1];
				int l1 = (i1 - 128) / 32;
				int j2 = j1 / 64;
				for (int l2 = -26; l2 <= 26; l2++) {
					for (int j3 = -26; j3 <= 26; j3++) {
						int k3 = l2 * 128;
						int i4 = j3 * 128;
						boolean flag2 = false;
						for (int k4 = -i; k4 <= j; k4 += 128) {
							if (!SceneGraph.method311(pixels[l1] + k4, i4, k3)) {
								continue;
							}
							flag2 = true;
							break;
						}
						aflag[l1][j2][l2 + 25 + 1][j3 + 25 + 1] = flag2;
					}
				}
			}
		}
		for (int k1 = 0; k1 < 8; k1++) {
			for (int i2 = 0; i2 < 32; i2++) {
				for (int k2 = -25; k2 < 25; k2++) {
					for (int i3 = -25; i3 < 25; i3++) {
						boolean flag1 = false;
						label0: for (int l3 = -1; l3 <= 1; l3++) {
							for (int j4 = -1; j4 <= 1; j4++) {
								if (aflag[k1][i2][k2 + l3 + 25 + 1][i3 + j4 + 25 + 1]) {
									flag1 = true;
								} else if (aflag[k1][(i2 + 1) % 31][k2 + l3 + 25 + 1][i3 + j4 + 25
								+ 1]) {
									flag1 = true;
								} else if (aflag[k1 + 1][i2][k2 + l3 + 25 + 1][i3 + j4 + 25 + 1]) {
									flag1 = true;
								} else {
									if (!aflag[k1 + 1][(i2 + 1) % 31][k2 + l3 + 25 + 1][i3 + j4
									+ 25 + 1]) {
										continue;
									}
									flag1 = true;
								}
								break label0;
							}
						}
						SceneGraph.aBooleanArrayArrayArrayArray491[k1][i2][k2 + 25][i3 + 25] = flag1;
					}
				}
			}
		}
	}

	private static boolean method311(int i, int j, int k) {
		int l = j * SceneGraph.sineYaw + k * SceneGraph.cosineYaw >> 16;
		int i1 = j * SceneGraph.cosineYaw - k * SceneGraph.sineYaw >> 16;
		int j1 = i * SceneGraph.sinePitch + i1 * SceneGraph.cosinePitch >> 16;
		int k1 = i * SceneGraph.cosinePitch - i1 * SceneGraph.sinePitch >> 16;
		if ((j1 < 50) || (j1 > 3500)) {
			return false;
		}
		int l1 = SceneGraph.anInt493 + (l << 9) / j1;
		int i2 = SceneGraph.anInt494 + (k1 << 9) / j1;
		return (l1 >= SceneGraph.anInt495) && (l1 <= SceneGraph.anInt497)
		&& (i2 >= SceneGraph.anInt496) && (i2 <= SceneGraph.anInt498);
	}

	public static void nullLoader() {
		SceneGraph.aClass28Array462 = null;
		SceneGraph.anIntArray473 = null;
		SceneGraph.aClass47ArrayArray474 = null;
		SceneGraph.aClass19_477 = null;
		SceneGraph.aBooleanArrayArrayArrayArray491 = null;
		SceneGraph.aBooleanArrayArray492 = null;
	}

	public void clearObjectActions() {
		for (int i = 0; i < interactiveObjectActions; i++) {
			InteractiveObject interactiveObject = actions[i];
			method289(interactiveObject);
			actions[i] = null;
		}
		interactiveObjectActions = 0;
	}

	public void initToNull() {
		for (int j = 0; j < anInt437; j++) {
			for (int k = 0; k < anInt438; k++) {
				for (int i1 = 0; i1 < anInt439; i1++) {
					groundArray[j][k][i1] = null;
				}
			}
		}
		for (int l = 0; l < SceneGraph.anInt472; l++) {
			for (int j1 = 0; j1 < SceneGraph.anIntArray473[l]; j1++) {
				SceneGraph.aClass47ArrayArray474[l][j1] = null;
			}
			SceneGraph.anIntArray473[l] = 0;
		}
		for (int k1 = 0; k1 < interactiveObjectActions; k1++) {
			actions[k1] = null;
		}
		interactiveObjectActions = 0;
		for (int l1 = 0; l1 < SceneGraph.aClass28Array462.length; l1++) {
			SceneGraph.aClass28Array462[l1] = null;
		}
	}

	public void method275(int i) {
		anInt442 = i;
		for (int k = 0; k < anInt438; k++) {
			for (int l = 0; l < anInt439; l++) {
				if (groundArray[i][k][l] == null) {
					groundArray[i][k][l] = new Tile(i, k, l);
				}
			}
		}
	}

	public void method276(int i, int j) {
		Tile tile = groundArray[0][j][i];
		for (int l = 0; l < 3; l++) {
			Tile objectTile = groundArray[l][j][i] = groundArray[l + 1][j][i];
			if (objectTile != null) {
				objectTile.anInt1307--;
				for (int j1 = 0; j1 < objectTile.anInt1317; j1++) {
					InteractiveObject interactiveObject = objectTile.interactiveObjects[j1];
					if (((interactiveObject.uid >> 29 & 3) == 2) && (interactiveObject.x == j)
					&& (interactiveObject.y == i)) {
						interactiveObject.z--;
					}
				}
			}
		}
		if (groundArray[0][j][i] == null) {
			groundArray[0][j][i] = new Tile(0, j, i);
		}
		groundArray[0][j][i].tile = tile;
		groundArray[3][j][i] = null;
	}

	public void method278(int i, int j, int k, int l) {
		Tile tile = groundArray[i][j][k];
		if (tile != null) {
			groundArray[i][j][k].anInt1321 = l;
		}
	}

	public void method279(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2,
	int j2, int k2, int l2, int i3, int j3, int k3, int l3, int i4, int j4, int k4, int l4) {
		if (l == 0) {
			MapTile mapTile = new MapTile(k2, l2, i3, j3, -1, k4, false);
			for (int i5 = i; i5 >= 0; i5--) {
				if (groundArray[i5][j][k] == null) {
					groundArray[i5][j][k] = new Tile(i5, j, k);
				}
			}
			groundArray[i][j][k].mapTile = mapTile;
			return;
		}
		if (l == 1) {
			MapTile class43_1 = new MapTile(k3, l3, i4, j4, j1, l4, (k1 == l1) && (k1 == i2)
			&& (k1 == j2));
			for (int j5 = i; j5 >= 0; j5--) {
				if (groundArray[j5][j][k] == null) {
					groundArray[j5][j][k] = new Tile(j5, j, k);
				}
			}
			groundArray[i][j][k].mapTile = class43_1;
			return;
		}
		ShapedMapTile shapedMapTile = new ShapedMapTile(k, k3, j3, i2, j1, i4, i1, k2, k4, i3, j2,
		l1, k1, l, j4, l3, l2, j, l4);
		for (int k5 = i; k5 >= 0; k5--) {
			if (groundArray[k5][j][k] == null) {
				groundArray[k5][j][k] = new Tile(k5, j, k);
			}
		}
		groundArray[i][j][k].shapedMapTile = shapedMapTile;
	}

	public void method280(int i, int j, int k, SceneModel sceneModel, byte data, int i1, int j1) {
		if (sceneModel == null) {
			return;
		}
		GroundDecoration groundDecoration = new GroundDecoration();
		groundDecoration.animation = sceneModel;
		groundDecoration.x = j1 * 128 + 64;
		groundDecoration.y = k * 128 + 64;
		groundDecoration.z = j;
		groundDecoration.uid = i1;
		groundDecoration.objectConfiguration = data;
		if (groundArray[i][j1][k] == null) {
			groundArray[i][j1][k] = new Tile(i, j1, k);
		}
		groundArray[i][j1][k].groundDecoration = groundDecoration;
	}

	public void method281(int i, int j, SceneModel sceneModel, int k, SceneModel sceneModel_1, SceneModel sceneModel_2, int l,
	int i1) {
		GroundItem groundItem = new GroundItem();
		groundItem.aClass30_Sub2_Sub4_48 = sceneModel_2;
		groundItem.anInt46 = i * 128 + 64;
		groundItem.anInt47 = i1 * 128 + 64;
		groundItem.anInt45 = k;
		groundItem.uid = j;
		groundItem.aClass30_Sub2_Sub4_49 = sceneModel;
		groundItem.aClass30_Sub2_Sub4_50 = sceneModel_1;
		int j1 = 0;
		Tile tile = groundArray[l][i][i1];
		if (tile != null) {
			for (int k1 = 0; k1 < tile.anInt1317; k1++) {
				if (tile.interactiveObjects[k1].animation instanceof Model) {
					int l1 = ((Model) tile.interactiveObjects[k1].animation).anInt1654;
					if (l1 > j1) {
						j1 = l1;
					}
				}
			}
		}
		groundItem.anInt52 = j1;
		if (groundArray[l][i][i1] == null) {
			groundArray[l][i][i1] = new Tile(l, i, i1);
		}
		groundArray[l][i][i1].groundItem = groundItem;
	}

	public void method282(int i, SceneModel sceneModel, int j, int k, byte byte0, int l, SceneModel sceneModel_1,
	int i1, int j1, int k1) {
		if ((sceneModel == null) && (sceneModel_1 == null)) {
			return;
		}
		WallObject wallObject = new WallObject();
		wallObject.uid = j;
		wallObject.aByte281 = byte0;
		wallObject.anInt274 = l * 128 + 64;
		wallObject.anInt275 = k * 128 + 64;
		wallObject.anInt273 = i1;
		wallObject.aClass30_Sub2_Sub4_278 = sceneModel;
		wallObject.aClass30_Sub2_Sub4_279 = sceneModel_1;
		wallObject.orientation = i;
		wallObject.orientation1 = j1;
		for (int l1 = k1; l1 >= 0; l1--) {
			if (groundArray[l1][l][k] == null) {
				groundArray[l1][l][k] = new Tile(l1, l, k);
			}
		}
		groundArray[k1][l][k].wallObject = wallObject;
	}

	public void method283(int i, int j, int k, int i1, int j1, int k1, SceneModel sceneModel, int l1,
	byte data, int i2, int j2) {
		if (sceneModel == null) {
			return;
		}
		WallDecoration class26 = new WallDecoration();
		class26.uid = i;
		class26.objectConfiguration = data;
		class26.anInt500 = l1 * 128 + 64 + j1;
		class26.anInt501 = j * 128 + 64 + i2;
		class26.anInt499 = k1;
		class26.animation = sceneModel;
		class26.anInt502 = j2;
		class26.anInt503 = k;
		for (int k2 = i1; k2 >= 0; k2--) {
			if (groundArray[k2][l1][j] == null) {
				groundArray[k2][l1][j] = new Tile(k2, l1, j);
			}
		}
		groundArray[i1][l1][j].wallDecoration = class26;
	}

	public boolean method284(int i, byte byte0, int j, int k, SceneModel sceneModel, int l, int i1, int j1,
	int k1, int l1) {
		if (sceneModel == null) {
			return true;
		} else {
			int i2 = l1 * 128 + 64 * l;
			int j2 = k1 * 128 + 64 * k;
			return method287(i1, l1, k1, l, k, i2, j2, j, sceneModel, j1, false, i, byte0);
		}
	}

	public boolean method285(int i, int j, int k, int l, int i1, int j1, int k1, SceneModel sceneModel,
	boolean flag) {
		if (sceneModel == null) {
			return true;
		}
		int l1 = k1 - j1;
		int i2 = i1 - j1;
		int j2 = k1 + j1;
		int k2 = i1 + j1;
		if (flag) {
			if ((j > 640) && (j < 1408)) {
				k2 += 128;
			}
			if ((j > 1152) && (j < 1920)) {
				j2 += 128;
			}
			if ((j > 1664) || (j < 384)) {
				i2 -= 128;
			}
			if ((j > 128) && (j < 896)) {
				l1 -= 128;
			}
		}
		l1 /= 128;
		i2 /= 128;
		j2 /= 128;
		k2 /= 128;
		return method287(i, l1, i2, (j2 - l1) + 1, (k2 - i2) + 1, k1, i1, k, sceneModel, j, true, l,
		(byte) 0);
	}

	public boolean method286(int j, int k, SceneModel sceneModel, int l, int i1, int j1, int k1, int l1,
	int i2, int j2, int k2) {
		return (sceneModel == null)
		|| method287(j, l1, k2, (i2 - l1) + 1, (i1 - k2) + 1, j1, k, k1, sceneModel, l, true, j2,
		(byte) 0);
	}

	private boolean method287(int i, int j, int k, int l, int i1, int j1, int k1, int l1,
	SceneModel sceneModel, int i2, boolean flag, int j2, byte byte0) {
		for (int k2 = j; k2 < j + l; k2++) {
			for (int l2 = k; l2 < k + i1; l2++) {
				if ((k2 < 0) || (l2 < 0) || (k2 >= anInt438) || (l2 >= anInt439)) {
					return false;
				}
				Tile tile = groundArray[i][k2][l2];
				if ((tile != null) && (tile.anInt1317 >= 5)) {
					return false;
				}
			}
		}
		InteractiveObject class28 = new InteractiveObject();
		class28.uid = j2;
		class28.objectConfiguration = byte0;
		class28.z = i;
		class28.anInt519 = j1;
		class28.anInt520 = k1;
		class28.anInt518 = l1;
		class28.animation = sceneModel;
		class28.anInt522 = i2;
		class28.x = j;
		class28.y = k;
		class28.anInt524 = (j + l) - 1;
		class28.anInt526 = (k + i1) - 1;
		for (int i3 = j; i3 < j + l; i3++) {
			for (int j3 = k; j3 < k + i1; j3++) {
				int k3 = 0;
				if (i3 > j) {
					k3++;
				}
				if (i3 < (j + l) - 1) {
					k3 += 4;
				}
				if (j3 > k) {
					k3 += 8;
				}
				if (j3 < (k + i1) - 1) {
					k3 += 2;
				}
				for (int l3 = i; l3 >= 0; l3--) {
					if (groundArray[l3][i3][j3] == null) {
						groundArray[l3][i3][j3] = new Tile(l3, i3, j3);
					}
				}
				Tile tile = groundArray[i][i3][j3];
				tile.interactiveObjects[tile.anInt1317] = class28;
				tile.anIntArray1319[tile.anInt1317] = k3;
				tile.anInt1320 |= k3;
				tile.anInt1317++;
			}
		}
		if (flag) {
			actions[interactiveObjectActions++] = class28;
		}
		return true;
	}

	private void method289(InteractiveObject interactiveObject) {
		for (int j = interactiveObject.x; j <= interactiveObject.anInt524; j++) {
			for (int k = interactiveObject.y; k <= interactiveObject.anInt526; k++) {
				Tile tile = groundArray[interactiveObject.z][j][k];
				if (tile != null) {
					for (int l = 0; l < tile.anInt1317; l++) {
						if (tile.interactiveObjects[l] != interactiveObject) {
							continue;
						}
						tile.anInt1317--;
						for (int i1 = l; i1 < tile.anInt1317; i1++) {
							tile.interactiveObjects[i1] = tile.interactiveObjects[i1 + 1];
							tile.anIntArray1319[i1] = tile.anIntArray1319[i1 + 1];
						}
						tile.interactiveObjects[tile.anInt1317] = null;
						break;
					}
					tile.anInt1320 = 0;
					for (int j1 = 0; j1 < tile.anInt1317; j1++) {
						tile.anInt1320 |= tile.anIntArray1319[j1];
					}
				}
			}
		}
	}

	public void method290(int i, int k, int l, int i1) {
		Tile tile = groundArray[i1][l][i];
		if (tile == null) {
			return;
		}
		WallDecoration wallDecoration = tile.wallDecoration;
		if (wallDecoration != null) {
			int j1 = l * 128 + 64;
			int k1 = i * 128 + 64;
			wallDecoration.anInt500 = j1 + ((wallDecoration.anInt500 - j1) * k) / 16;
			wallDecoration.anInt501 = k1 + ((wallDecoration.anInt501 - k1) * k) / 16;
		}
	}

	public void method291(int i, int j, int k, byte dummy) {
		Tile tile = groundArray[j][i][k];
		if (dummy != -119) {
			aBoolean434 = !aBoolean434;
		}
		if (tile != null) {
			tile.wallObject = null;
		}
	}

	public void method292(int j, int k, int l) {
		Tile tile = groundArray[k][l][j];
		if (tile != null) {
			tile.wallDecoration = null;
		}
	}

	public void method293(int i, int k, int l) {
		Tile tile = groundArray[i][k][l];
		if (tile == null) {
			return;
		}
		for (int j1 = 0; j1 < tile.anInt1317; j1++) {
			InteractiveObject class28 = tile.interactiveObjects[j1];
			if (((class28.uid >> 29 & 3) == 2) && (class28.x == k) && (class28.y == l)) {
				method289(class28);
				return;
			}
		}
	}

	public void method294(int i, int j, int k) {
		Tile tile = groundArray[i][k][j];
		if (tile == null) {
			return;
		}
		tile.groundDecoration = null;
	}

	public void method295(int i, int j, int k) {
		Tile tile = groundArray[i][j][k];
		if (tile != null) {
			tile.groundItem = null;
		}
	}

	public WallObject method296(int i, int j, int k) {
		Tile tile = groundArray[i][j][k];
		if (tile == null) {
			return null;
		} else {
			return tile.wallObject;
		}
	}

	public WallDecoration method297(int i, int k, int l) {
		Tile tile = groundArray[l][i][k];
		if (tile == null) {
			return null;
		} else {
			return tile.wallDecoration;
		}
	}

	public InteractiveObject method298(int i, int j, int k) {
		Tile tile = groundArray[k][i][j];
		if (tile == null) {
			return null;
		}
		for (int l = 0; l < tile.anInt1317; l++) {
			InteractiveObject class28 = tile.interactiveObjects[l];
			if (((class28.uid >> 29 & 3) == 2) && (class28.x == i) && (class28.y == j)) {
				return class28;
			}
		}
		return null;
	}

	public GroundDecoration method299(int i, int j, int k) {
		Tile tile = groundArray[k][j][i];
		if ((tile == null) || (tile.groundDecoration == null)) {
			return null;
		} else {
			return tile.groundDecoration;
		}
	}

	public int method300(int i, int j, int k) {
		Tile tile = groundArray[i][j][k];
		if ((tile == null) || (tile.wallObject == null)) {
			return 0;
		} else {
			return tile.wallObject.uid;
		}
	}

	public int method301(int i, int j, int l) {
		Tile tile = groundArray[i][j][l];
		if ((tile == null) || (tile.wallDecoration == null)) {
			return 0;
		} else {
			return tile.wallDecoration.uid;
		}
	}

	public int method302(int i, int j, int k) {
		Tile tile = groundArray[i][j][k];
		if (tile == null) {
			return 0;
		}
		for (int l = 0; l < tile.anInt1317; l++) {
			InteractiveObject interactiveObject = tile.interactiveObjects[l];
			if (((interactiveObject.uid >> 29 & 3) == 2) && (interactiveObject.x == j)
			&& (interactiveObject.y == k)) {
				return interactiveObject.uid;
			}
		}
		return 0;
	}

	public int method303(int i, int j, int k) {
		Tile tile = groundArray[i][j][k];
		if ((tile == null) || (tile.groundDecoration == null)) {
			return 0;
		} else {
			return tile.groundDecoration.uid;
		}
	}

	public int method304(int i, int j, int k, int l) {
		Tile tile = groundArray[i][j][k];
		if (tile == null) {
			return -1;
		}
		if ((tile.wallObject != null) && (tile.wallObject.uid == l)) {
			return tile.wallObject.aByte281 & 0xff;
		}
		if ((tile.wallDecoration != null) && (tile.wallDecoration.uid == l)) {
			return tile.wallDecoration.objectConfiguration & 0xff;
		}
		if ((tile.groundDecoration != null) && (tile.groundDecoration.uid == l)) {
			return tile.groundDecoration.objectConfiguration & 0xff;
		}
		for (int i1 = 0; i1 < tile.anInt1317; i1++) {
			if (tile.interactiveObjects[i1].uid == l) {
				return tile.interactiveObjects[i1].objectConfiguration & 0xff;
			}
		}
		return -1;
	}

	public void preProcessObjects(int i, int k, int i1) {
		int brightness = 64;// was parameter
		int shading = 768;// was parameter
		int j1 = (int) Math.sqrt(k * k + i * i + i1 * i1);
		int k1 = shading * j1 >> 8;
		for (int l1 = 0; l1 < anInt437; l1++) {
			for (int i2 = 0; i2 < anInt438; i2++) {
				for (int j2 = 0; j2 < anInt439; j2++) {
					Tile tile = groundArray[l1][i2][j2];
					if (tile != null) {
						WallObject wallObject = tile.wallObject;
						if ((wallObject != null) && (wallObject.aClass30_Sub2_Sub4_278 != null)
						&& (wallObject.aClass30_Sub2_Sub4_278.vertices != null)) {
							method307(l1, 1, 1, i2, j2,
							(Model) wallObject.aClass30_Sub2_Sub4_278);
							if ((wallObject.aClass30_Sub2_Sub4_279 != null)
							&& (wallObject.aClass30_Sub2_Sub4_279.vertices != null)) {
								method307(l1, 1, 1, i2, j2,
								(Model) wallObject.aClass30_Sub2_Sub4_279);
								method308((Model) wallObject.aClass30_Sub2_Sub4_278,
								(Model) wallObject.aClass30_Sub2_Sub4_279, 0, 0, 0, false);
								((Model) wallObject.aClass30_Sub2_Sub4_279).method480(
								brightness, k1, k, i, i1);
							}
							((Model) wallObject.aClass30_Sub2_Sub4_278).method480(brightness,
							k1, k, i, i1);
						}
						for (int k2 = 0; k2 < tile.anInt1317; k2++) {
							InteractiveObject class28 = tile.interactiveObjects[k2];
							if ((class28 != null) && (class28.animation != null)
							&& (class28.animation.vertices != null)) {
								method307(l1, (class28.anInt524 - class28.x) + 1,
								(class28.anInt526 - class28.y) + 1, i2, j2,
								(Model) class28.animation);
								((Model) class28.animation).method480(brightness, k1, k, i,
								i1);
							}
						}
						GroundDecoration groundDecoration = tile.groundDecoration;
						if ((groundDecoration != null)
						&& (groundDecoration.animation.vertices != null)) {
							method306(i2, l1, (Model) groundDecoration.animation, j2);
							((Model) groundDecoration.animation).method480(brightness, k1, k,
							i, i1);
						}
					}
				}
			}
		}
	}

	private void method306(int i, int j, Model model, int k) {
		if (i < anInt438) {
			Tile tile = groundArray[j][i + 1][k];
			if ((tile != null) && (tile.groundDecoration != null)
			&& (tile.groundDecoration.animation.vertices != null)) {
				method308(model, (Model) tile.groundDecoration.animation, 128, 0, 0,
				true);
			}
		}
		if (k < anInt438) {
			Tile tile = groundArray[j][i][k + 1];
			if ((tile != null) && (tile.groundDecoration != null)
			&& (tile.groundDecoration.animation.vertices != null)) {
				method308(model, (Model) tile.groundDecoration.animation, 0, 0, 128,
				true);
			}
		}
		if ((i < anInt438) && (k < anInt439)) {
			Tile tile = groundArray[j][i + 1][k + 1];
			if ((tile != null) && (tile.groundDecoration != null)
			&& (tile.groundDecoration.animation.vertices != null)) {
				method308(model, (Model) tile.groundDecoration.animation, 128, 0, 128,
				true);
			}
		}
		if ((i < anInt438) && (k > 0)) {
			Tile tile = groundArray[j][i + 1][k - 1];
			if ((tile != null) && (tile.groundDecoration != null)
			&& (tile.groundDecoration.animation.vertices != null)) {
				method308(model, (Model) tile.groundDecoration.animation, 128, 0, -128,
				true);
			}
		}
	}

	private void method307(int i, int j, int k, int l, int i1, Model model) {
		boolean flag = true;
		int j1 = l;
		int k1 = l + j;
		int l1 = i1 - 1;
		int i2 = i1 + k;
		for (int j2 = i; j2 <= i + 1; j2++) {
			if (j2 != anInt437) {
				for (int k2 = j1; k2 <= k1; k2++) {
					if ((k2 >= 0) && (k2 < anInt438)) {
						for (int l2 = l1; l2 <= i2; l2++) {
							if ((l2 >= 0) && (l2 < anInt439)
							&& (!flag || (k2 >= k1) || (l2 >= i2) || ((l2 < i1) && (k2 != l)))) {
								Tile tile = groundArray[j2][k2][l2];
								if (tile != null) {
									int i3 = (anIntArrayArrayArray440[j2][k2][l2]
									+ anIntArrayArrayArray440[j2][k2 + 1][l2]
									+ anIntArrayArrayArray440[j2][k2][l2 + 1] + anIntArrayArrayArray440[j2][k2 + 1][l2 + 1])
									/ 4
									- (anIntArrayArrayArray440[i][l][i1]
									+ anIntArrayArrayArray440[i][l + 1][i1]
									+ anIntArrayArrayArray440[i][l][i1 + 1] + anIntArrayArrayArray440[i][l + 1][i1 + 1])
									/ 4;
									WallObject wallObject = tile.wallObject;
									if ((wallObject != null)
									&& (wallObject.aClass30_Sub2_Sub4_278 != null)
									&& (wallObject.aClass30_Sub2_Sub4_278.vertices != null)) {
										method308(model,
										(Model) wallObject.aClass30_Sub2_Sub4_278, (k2 - l)
										* 128 + (1 - j) * 64, i3, (l2 - i1) * 128 + (1 - k) * 64,
										flag);
									}
									if ((wallObject != null)
									&& (wallObject.aClass30_Sub2_Sub4_279 != null)
									&& (wallObject.aClass30_Sub2_Sub4_279.vertices != null)) {
										method308(model,
										(Model) wallObject.aClass30_Sub2_Sub4_279, (k2 - l)
										* 128 + (1 - j) * 64, i3, (l2 - i1) * 128 + (1 - k) * 64,
										flag);
									}
									for (int j3 = 0; j3 < tile.anInt1317; j3++) {
										InteractiveObject interactiveObject = tile.interactiveObjects[j3];
										if ((interactiveObject != null)
										&& (interactiveObject.animation != null)
										&& (interactiveObject.animation.vertices != null)) {
											int k3 = (interactiveObject.anInt524 - interactiveObject.x) + 1;
											int l3 = (interactiveObject.anInt526 - interactiveObject.y) + 1;
											method308(model,
											(Model) interactiveObject.animation,
											(interactiveObject.x - l) * 128 + (k3 - j) * 64, i3,
											(interactiveObject.y - i1) * 128 + (l3 - k) * 64, flag);
										}
									}
								}
							}
						}
					}
				}
				j1--;
				flag = false;
			}
		}
	}

	private void method308(Model model, Model model_1, int i, int j, int k,
	boolean flag) {
		anInt488++;
		int l = 0;
		int ai[] = model_1.verticesX;
		int i1 = model_1.vertexCount;
		for (int j1 = 0; j1 < model.vertexCount; j1++) {
			Vertex vertex = model.vertices[j1];
			Vertex class33_1 = model.offsets[j1];
			if (class33_1.anInt605 != 0) {
				int i2 = model.verticesY[j1] - j;
				if (i2 <= model_1.anInt1651) {
					int j2 = model.verticesX[j1] - i;
					if ((j2 >= model_1.anInt1646) && (j2 <= model_1.anInt1647)) {
						int k2 = model.verticesZ[j1] - k;
						if ((k2 >= model_1.anInt1649) && (k2 <= model_1.anInt1648)) {
							for (int l2 = 0; l2 < i1; l2++) {
								Vertex class33_2 = model_1.vertices[l2];
								Vertex class33_3 = model_1.offsets[l2];
								if ((j2 == ai[l2]) && (k2 == model_1.verticesZ[l2])
								&& (i2 == model_1.verticesY[l2]) && (class33_3.anInt605 != 0)) {
									vertex.anInt602 += class33_3.anInt602;
									vertex.anInt603 += class33_3.anInt603;
									vertex.anInt604 += class33_3.anInt604;
									vertex.anInt605 += class33_3.anInt605;
									class33_2.anInt602 += class33_1.anInt602;
									class33_2.anInt603 += class33_1.anInt603;
									class33_2.anInt604 += class33_1.anInt604;
									class33_2.anInt605 += class33_1.anInt605;
									l++;
									anIntArray486[j1] = anInt488;
									anIntArray487[l2] = anInt488;
								}
							}
						}
					}
				}
			}
		}
		if ((l < 3) || !flag) {
			return;
		}
		for (int k1 = 0; k1 < model.triangleCount; k1++) {
			if ((anIntArray486[model.triangleFacePoints1[k1]] == anInt488)
			&& (anIntArray486[model.triangleFacePoints2[k1]] == anInt488)
			&& (anIntArray486[model.triangleFacePoints3[k1]] == anInt488)) {
				model.renderTypes[k1] = -1;
			}
		}
		for (int l1 = 0; l1 < model_1.triangleCount; l1++) {
			if ((anIntArray487[model_1.triangleFacePoints1[l1]] == anInt488)
			&& (anIntArray487[model_1.triangleFacePoints2[l1]] == anInt488)
			&& (anIntArray487[model_1.triangleFacePoints3[l1]] == anInt488)) {
				model_1.renderTypes[l1] = -1;
			}
		}
	}

	public void method309(int ai[], int i, int k, int l, int i1) {
		int j = 512;// was parameter
		Tile tile = groundArray[k][l][i1];
		if (tile == null) {
			return;
		}
		MapTile mapTile = tile.mapTile;
		if (mapTile != null) {
			int j1 = mapTile.anInt722;
			if (j1 == 0) {
				return;
			}
			for (int k1 = 0; k1 < 4; k1++) {
				ai[i] = j1;
				ai[i + 1] = j1;
				ai[i + 2] = j1;
				ai[i + 3] = j1;
				i += j;
			}
			return;
		}
		ShapedMapTile shapedMapTile = tile.shapedMapTile;
		if (shapedMapTile == null) {
			return;
		}
		int l1 = shapedMapTile.anInt684;
		int i2 = shapedMapTile.anInt685;
		int j2 = shapedMapTile.anInt686;
		int k2 = shapedMapTile.anInt687;
		int ai1[] = anIntArrayArray489[l1];
		int ai2[] = anIntArrayArray490[i2];
		int l2 = 0;
		if (j2 != 0) {
			for (int i3 = 0; i3 < 4; i3++) {
				ai[i] = ai1[ai2[l2++]] != 0 ? k2 : j2;
				ai[i + 1] = ai1[ai2[l2++]] != 0 ? k2 : j2;
				ai[i + 2] = ai1[ai2[l2++]] != 0 ? k2 : j2;
				ai[i + 3] = ai1[ai2[l2++]] != 0 ? k2 : j2;
				i += j;
			}
			return;
		}
		for (int j3 = 0; j3 < 4; j3++) {
			if (ai1[ai2[l2++]] != 0) {
				ai[i] = k2;
			}
			if (ai1[ai2[l2++]] != 0) {
				ai[i + 1] = k2;
			}
			if (ai1[ai2[l2++]] != 0) {
				ai[i + 2] = k2;
			}
			if (ai1[ai2[l2++]] != 0) {
				ai[i + 3] = k2;
			}
			i += j;
		}
	}

	public void method312(int i, int j) {
		SceneGraph.aBoolean467 = true;
		SceneGraph.anInt468 = j;
		SceneGraph.anInt469 = i;
		SceneGraph.anInt470 = -1;
		SceneGraph.anInt471 = -1;
	}

	public void method313(int x, int y, int yaw, int z, int plane, int pitch) {
		if (x < 0) {
			x = 0;
		} else if (x >= anInt438 * 128) {
			x = anInt438 * 128 - 1;
		}
		if (y < 0) {
			y = 0;
		} else if (y >= anInt439 * 128) {
			y = anInt439 * 128 - 1;
		}
		SceneGraph.anInt448++;
		SceneGraph.sinePitch = Model.sineTable[pitch];
		SceneGraph.cosinePitch = Model.cosineTable[pitch];
		SceneGraph.sineYaw = Model.sineTable[yaw];
		SceneGraph.cosineYaw = Model.cosineTable[yaw];
		SceneGraph.aBooleanArrayArray492 = SceneGraph.aBooleanArrayArrayArrayArray491[(pitch - 128) / 32][yaw / 64];
		SceneGraph.anInt455 = x;
		SceneGraph.anInt456 = z;
		SceneGraph.anInt457 = y;
		SceneGraph.anInt453 = x / 128;
		SceneGraph.anInt454 = y / 128;
		SceneGraph.anInt447 = plane;
		SceneGraph.anInt449 = SceneGraph.anInt453 - 25;
		if (SceneGraph.anInt449 < 0) {
			SceneGraph.anInt449 = 0;
		}
		SceneGraph.anInt451 = SceneGraph.anInt454 - 25;
		if (SceneGraph.anInt451 < 0) {
			SceneGraph.anInt451 = 0;
		}
		SceneGraph.anInt450 = SceneGraph.anInt453 + 25;
		if (SceneGraph.anInt450 > anInt438) {
			SceneGraph.anInt450 = anInt438;
		}
		SceneGraph.anInt452 = SceneGraph.anInt454 + 25;
		if (SceneGraph.anInt452 > anInt439) {
			SceneGraph.anInt452 = anInt439;
		}
		method319();
		SceneGraph.anInt446 = 0;
		for (int k1 = anInt442; k1 < anInt437; k1++) {
			Tile tiles[][] = groundArray[k1];
			for (int i2 = SceneGraph.anInt449; i2 < SceneGraph.anInt450; i2++) {
				for (int k2 = SceneGraph.anInt451; k2 < SceneGraph.anInt452; k2++) {
					Tile tile = tiles[i2][k2];
					if (tile != null) {
						if ((tile.anInt1321 > plane)
						|| (!SceneGraph.aBooleanArrayArray492[(i2 - SceneGraph.anInt453) + 25][(k2 - SceneGraph.anInt454) + 25] && (anIntArrayArrayArray440[k1][i2][k2]
						- z < 2000))) {
							tile.aBoolean1322 = false;
							tile.aBoolean1323 = false;
							tile.anInt1325 = 0;
						} else {
							tile.aBoolean1322 = true;
							tile.aBoolean1323 = true;
							tile.aBoolean1324 = tile.anInt1317 > 0;
							SceneGraph.anInt446++;
						}
					}
				}
			}
		}
		for (int l1 = anInt442; l1 < anInt437; l1++) {
			Tile tiles[][] = groundArray[l1];
			for (int l2 = -25; l2 <= 0; l2++) {
				int i3 = SceneGraph.anInt453 + l2;
				int k3 = SceneGraph.anInt453 - l2;
				if ((i3 >= SceneGraph.anInt449) || (k3 < SceneGraph.anInt450)) {
					for (int i4 = -25; i4 <= 0; i4++) {
						int k4 = SceneGraph.anInt454 + i4;
						int i5 = SceneGraph.anInt454 - i4;
						if (i3 >= SceneGraph.anInt449) {
							if (k4 >= SceneGraph.anInt451) {
								Tile tile = tiles[i3][k4];
								if ((tile != null) && tile.aBoolean1322) {
									method314(tile, true);
								}
							}
							if (i5 < SceneGraph.anInt452) {
								Tile tile_1 = tiles[i3][i5];
								if ((tile_1 != null) && tile_1.aBoolean1322) {
									method314(tile_1, true);
								}
							}
						}
						if (k3 < SceneGraph.anInt450) {
							if (k4 >= SceneGraph.anInt451) {
								Tile tile_2 = tiles[k3][k4];
								if ((tile_2 != null) && tile_2.aBoolean1322) {
									method314(tile_2, true);
								}
							}
							if (i5 < SceneGraph.anInt452) {
								Tile tile_3 = tiles[k3][i5];
								if ((tile_3 != null) && tile_3.aBoolean1322) {
									method314(tile_3, true);
								}
							}
						}
						if (SceneGraph.anInt446 == 0) {
							SceneGraph.aBoolean467 = false;
							return;
						}
					}
				}
			}
		}
		for (int j2 = anInt442; j2 < anInt437; j2++) {
			Tile tiles[][] = groundArray[j2];
			for (int j3 = -25; j3 <= 0; j3++) {
				int l3 = SceneGraph.anInt453 + j3;
				int j4 = SceneGraph.anInt453 - j3;
				if ((l3 >= SceneGraph.anInt449) || (j4 < SceneGraph.anInt450)) {
					for (int l4 = -25; l4 <= 0; l4++) {
						int j5 = SceneGraph.anInt454 + l4;
						int k5 = SceneGraph.anInt454 - l4;
						if (l3 >= SceneGraph.anInt449) {
							if (j5 >= SceneGraph.anInt451) {
								Tile tile = tiles[l3][j5];
								if ((tile != null) && tile.aBoolean1322) {
									method314(tile, false);
								}
							}
							if (k5 < SceneGraph.anInt452) {
								Tile tile = tiles[l3][k5];
								if ((tile != null) && tile.aBoolean1322) {
									method314(tile, false);
								}
							}
						}
						if (j4 < SceneGraph.anInt450) {
							if (j5 >= SceneGraph.anInt451) {
								Tile tile = tiles[j4][j5];
								if ((tile != null) && tile.aBoolean1322) {
									method314(tile, false);
								}
							}
							if (k5 < SceneGraph.anInt452) {
								Tile tile = tiles[j4][k5];
								if ((tile != null) && tile.aBoolean1322) {
									method314(tile, false);
								}
							}
						}
						if (SceneGraph.anInt446 == 0) {
							SceneGraph.aBoolean467 = false;
							return;
						}
					}
				}
			}
		}
		SceneGraph.aBoolean467 = false;
	}

	private void method314(Tile tile, boolean flag) {
		SceneGraph.aClass19_477.insertBack(tile);
		do {
			Tile tile_;
			do {
				tile_ = (Tile) SceneGraph.aClass19_477.popFront();
				if (tile_ == null) {
					return;
				}
			} while (!tile_.aBoolean1323);
			int i = tile_.anInt1308;
			int j = tile_.anInt1309;
			int k = tile_.anInt1307;
			int l = tile_.anInt1310;
			Tile tiles[][] = groundArray[k];
			if (tile_.aBoolean1322) {
				if (flag) {
					if (k > 0) {
						Tile tile_2 = groundArray[k - 1][i][j];
						if ((tile_2 != null) && tile_2.aBoolean1323) {
							continue;
						}
					}
					if ((i <= SceneGraph.anInt453) && (i > SceneGraph.anInt449)) {
						Tile tile_3 = tiles[i - 1][j];
						if ((tile_3 != null) && tile_3.aBoolean1323
						&& (tile_3.aBoolean1322 || ((tile_.anInt1320 & 1) == 0))) {
							continue;
						}
					}
					if ((i >= SceneGraph.anInt453) && (i < SceneGraph.anInt450 - 1)) {
						Tile tile_4 = tiles[i + 1][j];
						if ((tile_4 != null) && tile_4.aBoolean1323
						&& (tile_4.aBoolean1322 || ((tile_.anInt1320 & 4) == 0))) {
							continue;
						}
					}
					if ((j <= SceneGraph.anInt454) && (j > SceneGraph.anInt451)) {
						Tile tile_5 = tiles[i][j - 1];
						if ((tile_5 != null) && tile_5.aBoolean1323
						&& (tile_5.aBoolean1322 || ((tile_.anInt1320 & 8) == 0))) {
							continue;
						}
					}
					if ((j >= SceneGraph.anInt454) && (j < SceneGraph.anInt452 - 1)) {
						Tile tile_6 = tiles[i][j + 1];
						if ((tile_6 != null) && tile_6.aBoolean1323
						&& (tile_6.aBoolean1322 || ((tile_.anInt1320 & 2) == 0))) {
							continue;
						}
					}
				} else {
					flag = true;
				}
				tile_.aBoolean1322 = false;
				if (tile_.tile != null) {
					Tile tile_7 = tile_.tile;
					if (tile_7.mapTile != null) {
						if (!method320(0, i, j)) {
							method315(tile_7.mapTile, 0, SceneGraph.sinePitch,
							SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw, i, j);
						}
					} else if ((tile_7.shapedMapTile != null) && !method320(0, i, j)) {
						method316(i, SceneGraph.sinePitch, SceneGraph.sineYaw,
						tile_7.shapedMapTile, SceneGraph.cosinePitch, j, SceneGraph.cosineYaw);
					}
					WallObject wallObject = tile_7.wallObject;
					if (wallObject != null) {
						wallObject.aClass30_Sub2_Sub4_278.render(0, SceneGraph.sinePitch,
						SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
						wallObject.anInt274 - SceneGraph.anInt455, wallObject.anInt273
						- SceneGraph.anInt456, wallObject.anInt275 - SceneGraph.anInt457,
						wallObject.uid);
					}
					for (int i2 = 0; i2 < tile_7.anInt1317; i2++) {
						InteractiveObject interactiveObject = tile_7.interactiveObjects[i2];
						if (interactiveObject != null) {
							interactiveObject.animation
							.render(interactiveObject.anInt522, SceneGraph.sinePitch,
							SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
							interactiveObject.anInt519 - SceneGraph.anInt455,
							interactiveObject.anInt518 - SceneGraph.anInt456,
							interactiveObject.anInt520 - SceneGraph.anInt457, interactiveObject.uid);
						}
					}
				}
				boolean flag1 = false;
				if (tile_.mapTile != null) {
					if (!method320(l, i, j)) {
						flag1 = true;
						method315(tile_.mapTile, l, SceneGraph.sinePitch, SceneGraph.cosinePitch,
						SceneGraph.sineYaw, SceneGraph.cosineYaw, i, j);
					}
				} else if ((tile_.shapedMapTile != null) && !method320(l, i, j)) {
					flag1 = true;
					method316(i, SceneGraph.sinePitch, SceneGraph.sineYaw, tile_.shapedMapTile,
					SceneGraph.cosinePitch, j, SceneGraph.cosineYaw);
				}
				int j1 = 0;
				int j2 = 0;
				WallObject wallObject = tile_.wallObject;
				WallDecoration wallDecoration = tile_.wallDecoration;
				if ((wallObject != null) || (wallDecoration != null)) {
					if (SceneGraph.anInt453 == i) {
						j1++;
					} else if (SceneGraph.anInt453 < i) {
						j1 += 2;
					}
					if (SceneGraph.anInt454 == j) {
						j1 += 3;
					} else if (SceneGraph.anInt454 > j) {
						j1 += 6;
					}
					j2 = SceneGraph.anIntArray478[j1];
					tile_.anInt1328 = SceneGraph.anIntArray480[j1];
				}
				if (wallObject != null) {
					if ((wallObject.orientation & SceneGraph.anIntArray479[j1]) != 0) {
						if (wallObject.orientation == 16) {
							tile_.anInt1325 = 3;
							tile_.anInt1326 = SceneGraph.anIntArray481[j1];
							tile_.anInt1327 = 3 - tile_.anInt1326;
						} else if (wallObject.orientation == 32) {
							tile_.anInt1325 = 6;
							tile_.anInt1326 = SceneGraph.anIntArray482[j1];
							tile_.anInt1327 = 6 - tile_.anInt1326;
						} else if (wallObject.orientation == 64) {
							tile_.anInt1325 = 12;
							tile_.anInt1326 = SceneGraph.anIntArray483[j1];
							tile_.anInt1327 = 12 - tile_.anInt1326;
						} else {
							tile_.anInt1325 = 9;
							tile_.anInt1326 = SceneGraph.anIntArray484[j1];
							tile_.anInt1327 = 9 - tile_.anInt1326;
						}
					} else {
						tile_.anInt1325 = 0;
					}
					if (((wallObject.orientation & j2) != 0)
					&& !method321(l, i, j, wallObject.orientation)) {
						wallObject.aClass30_Sub2_Sub4_278.render(0, SceneGraph.sinePitch,
						SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
						wallObject.anInt274 - SceneGraph.anInt455, wallObject.anInt273
						- SceneGraph.anInt456, wallObject.anInt275 - SceneGraph.anInt457,
						wallObject.uid);
					}
					if (((wallObject.orientation1 & j2) != 0)
					&& !method321(l, i, j, wallObject.orientation1)) {
						wallObject.aClass30_Sub2_Sub4_279.render(0, SceneGraph.sinePitch,
						SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
						wallObject.anInt274 - SceneGraph.anInt455, wallObject.anInt273
						- SceneGraph.anInt456, wallObject.anInt275 - SceneGraph.anInt457,
						wallObject.uid);
					}
				}
				if ((wallDecoration != null)
				&& !method322(l, i, j, wallDecoration.animation.modelHeight)) {
					if ((wallDecoration.anInt502 & j2) != 0) {
						wallDecoration.animation.render(wallDecoration.anInt503,
						SceneGraph.sinePitch, SceneGraph.cosinePitch, SceneGraph.sineYaw,
						SceneGraph.cosineYaw, wallDecoration.anInt500 - SceneGraph.anInt455,
						wallDecoration.anInt499 - SceneGraph.anInt456, wallDecoration.anInt501
						- SceneGraph.anInt457, wallDecoration.uid);
					} else if ((wallDecoration.anInt502 & 0x300) != 0) {
						int j4 = wallDecoration.anInt500 - SceneGraph.anInt455;
						int l5 = wallDecoration.anInt499 - SceneGraph.anInt456;
						int k6 = wallDecoration.anInt501 - SceneGraph.anInt457;
						int i8 = wallDecoration.anInt503;
						int k9;
						if ((i8 == 1) || (i8 == 2)) {
							k9 = -j4;
						} else {
							k9 = j4;
						}
						int k10;
						if ((i8 == 2) || (i8 == 3)) {
							k10 = -k6;
						} else {
							k10 = k6;
						}
						if (((wallDecoration.anInt502 & 0x100) != 0) && (k10 < k9)) {
							int i11 = j4 + SceneGraph.anIntArray463[i8];
							int k11 = k6 + SceneGraph.anIntArray464[i8];
							wallDecoration.animation.render(i8 * 512 + 256, SceneGraph.sinePitch,
							SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw, i11,
							l5, k11, wallDecoration.uid);
						}
						if (((wallDecoration.anInt502 & 0x200) != 0) && (k10 > k9)) {
							int j11 = j4 + SceneGraph.anIntArray465[i8];
							int l11 = k6 + SceneGraph.anIntArray466[i8];
							wallDecoration.animation.render(i8 * 512 + 1280 & 0x7ff,
							SceneGraph.sinePitch, SceneGraph.cosinePitch, SceneGraph.sineYaw,
							SceneGraph.cosineYaw, j11, l5, l11, wallDecoration.uid);
						}
					}
				}
				if (flag1) {
					GroundDecoration groundDecoration = tile_.groundDecoration;
					if (groundDecoration != null) {
						groundDecoration.animation.render(0, SceneGraph.sinePitch,
						SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
						groundDecoration.x - SceneGraph.anInt455, groundDecoration.z
						- SceneGraph.anInt456, groundDecoration.y - SceneGraph.anInt457,
						groundDecoration.uid);
					}
					GroundItem groundItem = tile_.groundItem;
					if ((groundItem != null) && (groundItem.anInt52 == 0)) {
						if (groundItem.aClass30_Sub2_Sub4_49 != null) {
							groundItem.aClass30_Sub2_Sub4_49.render(0, SceneGraph.sinePitch,
							SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
							groundItem.anInt46 - SceneGraph.anInt455, groundItem.anInt45
							- SceneGraph.anInt456, groundItem.anInt47 - SceneGraph.anInt457,
							groundItem.uid);
						}
						if (groundItem.aClass30_Sub2_Sub4_50 != null) {
							groundItem.aClass30_Sub2_Sub4_50.render(0, SceneGraph.sinePitch,
							SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
							groundItem.anInt46 - SceneGraph.anInt455, groundItem.anInt45
							- SceneGraph.anInt456, groundItem.anInt47 - SceneGraph.anInt457,
							groundItem.uid);
						}
						if (groundItem.aClass30_Sub2_Sub4_48 != null) {
							groundItem.aClass30_Sub2_Sub4_48.render(0, SceneGraph.sinePitch,
							SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
							groundItem.anInt46 - SceneGraph.anInt455, groundItem.anInt45
							- SceneGraph.anInt456, groundItem.anInt47 - SceneGraph.anInt457,
							groundItem.uid);
						}
					}
				}
				int k4 = tile_.anInt1320;
				if (k4 != 0) {
					if ((i < SceneGraph.anInt453) && ((k4 & 4) != 0)) {
						Tile tile_17 = tiles[i + 1][j];
						if ((tile_17 != null) && tile_17.aBoolean1323) {
							SceneGraph.aClass19_477.insertBack(tile_17);
						}
					}
					if ((j < SceneGraph.anInt454) && ((k4 & 2) != 0)) {
						Tile tile_18 = tiles[i][j + 1];
						if ((tile_18 != null) && tile_18.aBoolean1323) {
							SceneGraph.aClass19_477.insertBack(tile_18);
						}
					}
					if ((i > SceneGraph.anInt453) && ((k4 & 1) != 0)) {
						Tile tile_19 = tiles[i - 1][j];
						if ((tile_19 != null) && tile_19.aBoolean1323) {
							SceneGraph.aClass19_477.insertBack(tile_19);
						}
					}
					if ((j > SceneGraph.anInt454) && ((k4 & 8) != 0)) {
						Tile tile_20 = tiles[i][j - 1];
						if ((tile_20 != null) && tile_20.aBoolean1323) {
							SceneGraph.aClass19_477.insertBack(tile_20);
						}
					}
				}
			}
			if (tile_.anInt1325 != 0) {
				boolean flag2 = true;
				for (int k1 = 0; k1 < tile_.anInt1317; k1++) {
					if ((tile_.interactiveObjects[k1].anInt528 == SceneGraph.anInt448)
					|| ((tile_.anIntArray1319[k1] & tile_.anInt1325) != tile_.anInt1326)) {
						continue;
					}
					flag2 = false;
					break;
				}
				if (flag2) {
					WallObject wallObject = tile_.wallObject;
					if (!method321(l, i, j, wallObject.orientation)) {
						wallObject.aClass30_Sub2_Sub4_278.render(0, SceneGraph.sinePitch,
						SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
						wallObject.anInt274 - SceneGraph.anInt455, wallObject.anInt273
						- SceneGraph.anInt456, wallObject.anInt275 - SceneGraph.anInt457,
						wallObject.uid);
					}
					tile_.anInt1325 = 0;
				}
			}
			if (tile_.aBoolean1324) {
				try {
					int i1 = tile_.anInt1317;
					tile_.aBoolean1324 = false;
					int l1 = 0;
					label0: for (int k2 = 0; k2 < i1; k2++) {
						InteractiveObject interactiveObject = tile_.interactiveObjects[k2];
						if (interactiveObject.anInt528 == SceneGraph.anInt448) {
							continue;
						}
						for (int k3 = interactiveObject.x; k3 <= interactiveObject.anInt524; k3++) {
							for (int l4 = interactiveObject.y; l4 <= interactiveObject.anInt526; l4++) {
								Tile tile_21 = tiles[k3][l4];
								if (tile_21.aBoolean1322) {
									tile_.aBoolean1324 = true;
								} else {
									if (tile_21.anInt1325 == 0) {
										continue;
									}
									int l6 = 0;
									if (k3 > interactiveObject.x) {
										l6++;
									}
									if (k3 < interactiveObject.anInt524) {
										l6 += 4;
									}
									if (l4 > interactiveObject.y) {
										l6 += 8;
									}
									if (l4 < interactiveObject.anInt526) {
										l6 += 2;
									}
									if ((l6 & tile_21.anInt1325) != tile_.anInt1327) {
										continue;
									}
									tile_.aBoolean1324 = true;
								}
								continue label0;
							}
						}
						SceneGraph.aClass28Array462[l1++] = interactiveObject;
						int i5 = SceneGraph.anInt453 - interactiveObject.x;
						int i6 = interactiveObject.anInt524 - SceneGraph.anInt453;
						if (i6 > i5) {
							i5 = i6;
						}
						int i7 = SceneGraph.anInt454 - interactiveObject.y;
						int j8 = interactiveObject.anInt526 - SceneGraph.anInt454;
						if (j8 > i7) {
							interactiveObject.anInt527 = i5 + j8;
						} else {
							interactiveObject.anInt527 = i5 + i7;
						}
					}
					while (l1 > 0) {
						int i3 = -50;
						int l3 = -1;
						for (int j5 = 0; j5 < l1; j5++) {
							InteractiveObject interactiveObject = SceneGraph.aClass28Array462[j5];
							if (interactiveObject.anInt528 != SceneGraph.anInt448) {
								if (interactiveObject.anInt527 > i3) {
									i3 = interactiveObject.anInt527;
									l3 = j5;
								} else if (interactiveObject.anInt527 == i3) {
									int j7 = interactiveObject.anInt519 - SceneGraph.anInt455;
									int k8 = interactiveObject.anInt520 - SceneGraph.anInt457;
									int l9 = SceneGraph.aClass28Array462[l3].anInt519
									- SceneGraph.anInt455;
									int l10 = SceneGraph.aClass28Array462[l3].anInt520
									- SceneGraph.anInt457;
									if (j7 * j7 + k8 * k8 > l9 * l9 + l10 * l10) {
										l3 = j5;
									}
								}
							}
						}
						if (l3 == -1) {
							break;
						}
						InteractiveObject interactiveObject = SceneGraph.aClass28Array462[l3];
						interactiveObject.anInt528 = SceneGraph.anInt448;
						if (!method323(l, interactiveObject.x, interactiveObject.anInt524,
						interactiveObject.y, interactiveObject.anInt526,
						interactiveObject.animation.modelHeight)) {
							interactiveObject.animation
							.render(interactiveObject.anInt522, SceneGraph.sinePitch,
							SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
							interactiveObject.anInt519 - SceneGraph.anInt455,
							interactiveObject.anInt518 - SceneGraph.anInt456,
							interactiveObject.anInt520 - SceneGraph.anInt457, interactiveObject.uid);
						}
						for (int k7 = interactiveObject.x; k7 <= interactiveObject.anInt524; k7++) {
							for (int l8 = interactiveObject.y; l8 <= interactiveObject.anInt526; l8++) {
								Tile tile_22 = tiles[k7][l8];
								if (tile_22.anInt1325 != 0) {
									SceneGraph.aClass19_477.insertBack(tile_22);
								} else if (((k7 != i) || (l8 != j)) && tile_22.aBoolean1323) {
									SceneGraph.aClass19_477.insertBack(tile_22);
								}
							}
						}
					}
					if (tile_.aBoolean1324) {
						continue;
					}
				} catch (Exception _ex) {
					tile_.aBoolean1324 = false;
				}
			}
			if (!tile_.aBoolean1323 || (tile_.anInt1325 != 0)) {
				continue;
			}
			if ((i <= SceneGraph.anInt453) && (i > SceneGraph.anInt449)) {
				Tile tile_8 = tiles[i - 1][j];
				if ((tile_8 != null) && tile_8.aBoolean1323) {
					continue;
				}
			}
			if ((i >= SceneGraph.anInt453) && (i < SceneGraph.anInt450 - 1)) {
				Tile tile_9 = tiles[i + 1][j];
				if ((tile_9 != null) && tile_9.aBoolean1323) {
					continue;
				}
			}
			if ((j <= SceneGraph.anInt454) && (j > SceneGraph.anInt451)) {
				Tile tile_10 = tiles[i][j - 1];
				if ((tile_10 != null) && tile_10.aBoolean1323) {
					continue;
				}
			}
			if ((j >= SceneGraph.anInt454) && (j < SceneGraph.anInt452 - 1)) {
				Tile tile_11 = tiles[i][j + 1];
				if ((tile_11 != null) && tile_11.aBoolean1323) {
					continue;
				}
			}
			tile_.aBoolean1323 = false;
			SceneGraph.anInt446--;
			GroundItem groundItem = tile_.groundItem;
			if ((groundItem != null) && (groundItem.anInt52 != 0)) {
				if (groundItem.aClass30_Sub2_Sub4_49 != null) {
					groundItem.aClass30_Sub2_Sub4_49.render(0, SceneGraph.sinePitch,
					SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
					groundItem.anInt46 - SceneGraph.anInt455, groundItem.anInt45
					- SceneGraph.anInt456 - groundItem.anInt52, groundItem.anInt47
					- SceneGraph.anInt457, groundItem.uid);
				}
				if (groundItem.aClass30_Sub2_Sub4_50 != null) {
					groundItem.aClass30_Sub2_Sub4_50.render(0, SceneGraph.sinePitch,
					SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
					groundItem.anInt46 - SceneGraph.anInt455, groundItem.anInt45
					- SceneGraph.anInt456 - groundItem.anInt52, groundItem.anInt47
					- SceneGraph.anInt457, groundItem.uid);
				}
				if (groundItem.aClass30_Sub2_Sub4_48 != null) {
					groundItem.aClass30_Sub2_Sub4_48.render(0, SceneGraph.sinePitch,
					SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
					groundItem.anInt46 - SceneGraph.anInt455, groundItem.anInt45
					- SceneGraph.anInt456 - groundItem.anInt52, groundItem.anInt47
					- SceneGraph.anInt457, groundItem.uid);
				}
			}
			if (tile_.anInt1328 != 0) {
				WallDecoration class26 = tile_.wallDecoration;
				if ((class26 != null) && !method322(l, i, j, class26.animation.modelHeight)) {
					if ((class26.anInt502 & tile_.anInt1328) != 0) {
						class26.animation.render(class26.anInt503, SceneGraph.sinePitch,
						SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
						class26.anInt500 - SceneGraph.anInt455, class26.anInt499
						- SceneGraph.anInt456, class26.anInt501 - SceneGraph.anInt457, class26.uid);
					} else if ((class26.anInt502 & 0x300) != 0) {
						int l2 = class26.anInt500 - SceneGraph.anInt455;
						int j3 = class26.anInt499 - SceneGraph.anInt456;
						int i4 = class26.anInt501 - SceneGraph.anInt457;
						int k5 = class26.anInt503;
						int j6;
						if ((k5 == 1) || (k5 == 2)) {
							j6 = -l2;
						} else {
							j6 = l2;
						}
						int l7;
						if ((k5 == 2) || (k5 == 3)) {
							l7 = -i4;
						} else {
							l7 = i4;
						}
						if (((class26.anInt502 & 0x100) != 0) && (l7 >= j6)) {
							int i9 = l2 + SceneGraph.anIntArray463[k5];
							int i10 = i4 + SceneGraph.anIntArray464[k5];
							class26.animation.render(k5 * 512 + 256, SceneGraph.sinePitch,
							SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw, i9,
							j3, i10, class26.uid);
						}
						if (((class26.anInt502 & 0x200) != 0) && (l7 <= j6)) {
							int j9 = l2 + SceneGraph.anIntArray465[k5];
							int j10 = i4 + SceneGraph.anIntArray466[k5];
							class26.animation.render(k5 * 512 + 1280 & 0x7ff, SceneGraph.sinePitch,
							SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw, j9,
							j3, j10, class26.uid);
						}
					}
				}
				WallObject wallObject = tile_.wallObject;
				if (wallObject != null) {
					if (((wallObject.orientation1 & tile_.anInt1328) != 0)
					&& !method321(l, i, j, wallObject.orientation1)) {
						wallObject.aClass30_Sub2_Sub4_279.render(0, SceneGraph.sinePitch,
						SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
						wallObject.anInt274 - SceneGraph.anInt455, wallObject.anInt273
						- SceneGraph.anInt456, wallObject.anInt275 - SceneGraph.anInt457,
						wallObject.uid);
					}
					if (((wallObject.orientation & tile_.anInt1328) != 0)
					&& !method321(l, i, j, wallObject.orientation)) {
						wallObject.aClass30_Sub2_Sub4_278.render(0, SceneGraph.sinePitch,
						SceneGraph.cosinePitch, SceneGraph.sineYaw, SceneGraph.cosineYaw,
						wallObject.anInt274 - SceneGraph.anInt455, wallObject.anInt273
						- SceneGraph.anInt456, wallObject.anInt275 - SceneGraph.anInt457,
						wallObject.uid);
					}
				}
			}
			if (k < anInt437 - 1) {
				Tile tile_12 = groundArray[k + 1][i][j];
				if ((tile_12 != null) && tile_12.aBoolean1323) {
					SceneGraph.aClass19_477.insertBack(tile_12);
				}
			}
			if (i < SceneGraph.anInt453) {
				Tile tile_13 = tiles[i + 1][j];
				if ((tile_13 != null) && tile_13.aBoolean1323) {
					SceneGraph.aClass19_477.insertBack(tile_13);
				}
			}
			if (j < SceneGraph.anInt454) {
				Tile tile_14 = tiles[i][j + 1];
				if ((tile_14 != null) && tile_14.aBoolean1323) {
					SceneGraph.aClass19_477.insertBack(tile_14);
				}
			}
			if (i > SceneGraph.anInt453) {
				Tile tile_15 = tiles[i - 1][j];
				if ((tile_15 != null) && tile_15.aBoolean1323) {
					SceneGraph.aClass19_477.insertBack(tile_15);
				}
			}
			if (j > SceneGraph.anInt454) {
				Tile tile_16 = tiles[i][j - 1];
				if ((tile_16 != null) && tile_16.aBoolean1323) {
					SceneGraph.aClass19_477.insertBack(tile_16);
				}
			}
		} while (true);
	}

	private void method315(MapTile mapTile, int i, int j, int k, int l, int i1, int j1, int k1) {
		int l1;
		int i2 = l1 = (j1 << 7) - SceneGraph.anInt455;
		int j2;
		int k2 = j2 = (k1 << 7) - SceneGraph.anInt457;
		int l2;
		int i3 = l2 = i2 + 128;
		int j3;
		int k3 = j3 = k2 + 128;
		int l3 = anIntArrayArrayArray440[i][j1][k1] - SceneGraph.anInt456;
		int i4 = anIntArrayArrayArray440[i][j1 + 1][k1] - SceneGraph.anInt456;
		int j4 = anIntArrayArrayArray440[i][j1 + 1][k1 + 1] - SceneGraph.anInt456;
		int k4 = anIntArrayArrayArray440[i][j1][k1 + 1] - SceneGraph.anInt456;
		int l4 = k2 * l + i2 * i1 >> 16;
		k2 = k2 * i1 - i2 * l >> 16;
		i2 = l4;
		l4 = l3 * k - k2 * j >> 16;
		k2 = l3 * j + k2 * k >> 16;
		l3 = l4;
		if (k2 < 50) {
			return;
		}
		l4 = j2 * l + i3 * i1 >> 16;
		j2 = j2 * i1 - i3 * l >> 16;
		i3 = l4;
		l4 = i4 * k - j2 * j >> 16;
		j2 = i4 * j + j2 * k >> 16;
		i4 = l4;
		if (j2 < 50) {
			return;
		}
		l4 = k3 * l + l2 * i1 >> 16;
		k3 = k3 * i1 - l2 * l >> 16;
		l2 = l4;
		l4 = j4 * k - k3 * j >> 16;
		k3 = j4 * j + k3 * k >> 16;
		j4 = l4;
		if (k3 < 50) {
			return;
		}
		l4 = j3 * l + l1 * i1 >> 16;
		j3 = j3 * i1 - l1 * l >> 16;
		l1 = l4;
		l4 = k4 * k - j3 * j >> 16;
		j3 = k4 * j + j3 * k >> 16;
		k4 = l4;
		if (j3 < 50) {
			return;
		}
		int i5 = Renderer3D.middleX + (i2 << 9) / k2;
		int j5 = Renderer3D.middleY + (l3 << 9) / k2;
		int k5 = Renderer3D.middleX + (i3 << 9) / j2;
		int l5 = Renderer3D.middleY + (i4 << 9) / j2;
		int i6 = Renderer3D.middleX + (l2 << 9) / k3;
		int j6 = Renderer3D.middleY + (j4 << 9) / k3;
		int k6 = Renderer3D.middleX + (l1 << 9) / j3;
		int l6 = Renderer3D.middleY + (k4 << 9) / j3;
		Renderer3D.alpha = 0;
		if ((i6 - k6) * (l5 - l6) - (j6 - l6) * (k5 - k6) > 0) {
			Renderer3D.edgeRestricted = (i6 < 0) || (k6 < 0) || (k5 < 0) || (i6 > Renderer2D.endX)
			|| (k6 > Renderer2D.endX) || (k5 > Renderer2D.endX);
			if (SceneGraph.aBoolean467
			&& method318(SceneGraph.anInt468, SceneGraph.anInt469, j6, l6, l5, i6, k6, k5)) {
				SceneGraph.anInt470 = j1;
				SceneGraph.anInt471 = k1;
			}
			if (mapTile.anInt720 == -1) {
				if (mapTile.anInt718 != 0xbc614e) {
					Renderer3D.drawShadedTriangle(j6, l6, l5, i6, k6, k5, mapTile.anInt718,
					mapTile.anInt719, mapTile.anInt717);
				}
			} else if (!SceneGraph.lowMem) {
				if (mapTile.aBoolean721) {
					Renderer3D.drawTexturedTriangle(j6, l6, l5, i6, k6, k5, mapTile.anInt718,
					mapTile.anInt719, mapTile.anInt717, i2, i3, l1, l3, i4, k4, k2, j2, j3,
					mapTile.anInt720);
				} else {
					Renderer3D.drawTexturedTriangle(j6, l6, l5, i6, k6, k5, mapTile.anInt718,
					mapTile.anInt719, mapTile.anInt717, l2, l1, i3, j4, k4, i4, k3, j3, j2,
					mapTile.anInt720);
				}
			} else {
				int i7 = SceneGraph.anIntArray485[mapTile.anInt720];
				Renderer3D
				.drawShadedTriangle(j6, l6, l5, i6, k6, k5, method317(i7, mapTile.anInt718),
				method317(i7, mapTile.anInt719), method317(i7, mapTile.anInt717));
			}
		}
		if ((i5 - k5) * (l6 - l5) - (j5 - l5) * (k6 - k5) > 0) {
			Renderer3D.edgeRestricted = (i5 < 0) || (k5 < 0) || (k6 < 0) || (i5 > Renderer2D.endX)
			|| (k5 > Renderer2D.endX) || (k6 > Renderer2D.endX);
			if (SceneGraph.aBoolean467
			&& method318(SceneGraph.anInt468, SceneGraph.anInt469, j5, l5, l6, i5, k5, k6)) {
				SceneGraph.anInt470 = j1;
				SceneGraph.anInt471 = k1;
			}
			if (mapTile.anInt720 == -1) {
				if (mapTile.anInt716 != 0xbc614e) {
					Renderer3D.drawShadedTriangle(j5, l5, l6, i5, k5, k6, mapTile.anInt716,
					mapTile.anInt717, mapTile.anInt719);
				}
			} else {
				if (!SceneGraph.lowMem) {
					Renderer3D.drawTexturedTriangle(j5, l5, l6, i5, k5, k6, mapTile.anInt716,
					mapTile.anInt717, mapTile.anInt719, i2, i3, l1, l3, i4, k4, k2, j2, j3,
					mapTile.anInt720);
					return;
				}
				int j7 = SceneGraph.anIntArray485[mapTile.anInt720];
				Renderer3D
				.drawShadedTriangle(j5, l5, l6, i5, k5, k6, method317(j7, mapTile.anInt716),
				method317(j7, mapTile.anInt717), method317(j7, mapTile.anInt719));
			}
		}
	}

	private void method316(int i, int j, int k, ShapedMapTile shapedMapTile, int l, int i1, int j1) {
		int k1 = shapedMapTile.anIntArray673.length;
		for (int l1 = 0; l1 < k1; l1++) {
			int i2 = shapedMapTile.anIntArray673[l1] - SceneGraph.anInt455;
			int k2 = shapedMapTile.anIntArray674[l1] - SceneGraph.anInt456;
			int i3 = shapedMapTile.anIntArray675[l1] - SceneGraph.anInt457;
			int k3 = i3 * k + i2 * j1 >> 16;
			i3 = i3 * j1 - i2 * k >> 16;
			i2 = k3;
			k3 = k2 * l - i3 * j >> 16;
			i3 = k2 * j + i3 * l >> 16;
			k2 = k3;
			if (i3 < 50) {
				return;
			}
			if (shapedMapTile.anIntArray682 != null) {
				ShapedMapTile.anIntArray690[l1] = i2;
				ShapedMapTile.anIntArray691[l1] = k2;
				ShapedMapTile.anIntArray692[l1] = i3;
			}
			ShapedMapTile.anIntArray688[l1] = Renderer3D.middleX + (i2 << 9) / i3;
			ShapedMapTile.anIntArray689[l1] = Renderer3D.middleY + (k2 << 9) / i3;
		}
		Renderer3D.alpha = 0;
		k1 = shapedMapTile.anIntArray679.length;
		for (int j2 = 0; j2 < k1; j2++) {
			int l2 = shapedMapTile.anIntArray679[j2];
			int j3 = shapedMapTile.anIntArray680[j2];
			int l3 = shapedMapTile.anIntArray681[j2];
			int i4 = ShapedMapTile.anIntArray688[l2];
			int j4 = ShapedMapTile.anIntArray688[j3];
			int k4 = ShapedMapTile.anIntArray688[l3];
			int l4 = ShapedMapTile.anIntArray689[l2];
			int i5 = ShapedMapTile.anIntArray689[j3];
			int j5 = ShapedMapTile.anIntArray689[l3];
			if ((i4 - j4) * (j5 - i5) - (l4 - i5) * (k4 - j4) > 0) {
				Renderer3D.edgeRestricted = (i4 < 0) || (j4 < 0) || (k4 < 0)
				|| (i4 > Renderer2D.endX) || (j4 > Renderer2D.endX) || (k4 > Renderer2D.endX);
				if (SceneGraph.aBoolean467
				&& method318(SceneGraph.anInt468, SceneGraph.anInt469, l4, i5, j5, i4, j4, k4)) {
					SceneGraph.anInt470 = i;
					SceneGraph.anInt471 = i1;
				}
				if ((shapedMapTile.anIntArray682 == null)
				|| (shapedMapTile.anIntArray682[j2] == -1)) {
					if (shapedMapTile.anIntArray676[j2] != 0xbc614e) {
						Renderer3D.drawShadedTriangle(l4, i5, j5, i4, j4, k4,
						shapedMapTile.anIntArray676[j2], shapedMapTile.anIntArray677[j2],
						shapedMapTile.anIntArray678[j2]);
					}
				} else if (!SceneGraph.lowMem) {
					if (shapedMapTile.aBoolean683) {
						Renderer3D.drawTexturedTriangle(l4, i5, j5, i4, j4, k4,
						shapedMapTile.anIntArray676[j2], shapedMapTile.anIntArray677[j2],
						shapedMapTile.anIntArray678[j2], ShapedMapTile.anIntArray690[0],
						ShapedMapTile.anIntArray690[1], ShapedMapTile.anIntArray690[3],
						ShapedMapTile.anIntArray691[0], ShapedMapTile.anIntArray691[1],
						ShapedMapTile.anIntArray691[3], ShapedMapTile.anIntArray692[0],
						ShapedMapTile.anIntArray692[1], ShapedMapTile.anIntArray692[3],
						shapedMapTile.anIntArray682[j2]);
					} else {
						Renderer3D.drawTexturedTriangle(l4, i5, j5, i4, j4, k4,
						shapedMapTile.anIntArray676[j2], shapedMapTile.anIntArray677[j2],
						shapedMapTile.anIntArray678[j2], ShapedMapTile.anIntArray690[l2],
						ShapedMapTile.anIntArray690[j3], ShapedMapTile.anIntArray690[l3],
						ShapedMapTile.anIntArray691[l2], ShapedMapTile.anIntArray691[j3],
						ShapedMapTile.anIntArray691[l3], ShapedMapTile.anIntArray692[l2],
						ShapedMapTile.anIntArray692[j3], ShapedMapTile.anIntArray692[l3],
						shapedMapTile.anIntArray682[j2]);
					}
				} else {
					int k5 = SceneGraph.anIntArray485[shapedMapTile.anIntArray682[j2]];
					Renderer3D.drawShadedTriangle(l4, i5, j5, i4, j4, k4, method317(k5,
					shapedMapTile.anIntArray676[j2]),
					method317(k5, shapedMapTile.anIntArray677[j2]), method317(k5,
					shapedMapTile.anIntArray678[j2]));
				}
			}
		}
	}

	private int method317(int j, int k) {
		k = 127 - k;
		k = (k * (j & 0x7f)) / 160;
		if (k < 2) {
			k = 2;
		} else if (k > 126) {
			k = 126;
		}
		return (j & 0xff80) + k;
	}

	private boolean method318(int i, int j, int k, int l, int i1, int j1, int k1, int l1) {
		if ((j < k) && (j < l) && (j < i1)) {
			return false;
		}
		if ((j > k) && (j > l) && (j > i1)) {
			return false;
		}
		if ((i < j1) && (i < k1) && (i < l1)) {
			return false;
		}
		if ((i > j1) && (i > k1) && (i > l1)) {
			return false;
		}
		int i2 = (j - k) * (k1 - j1) - (i - j1) * (l - k);
		int j2 = (j - i1) * (j1 - l1) - (i - l1) * (k - i1);
		int k2 = (j - l) * (l1 - k1) - (i - k1) * (i1 - l);
		return (i2 * k2 > 0) && (k2 * j2 > 0);
	}

	private void method319() {
		int j = SceneGraph.anIntArray473[SceneGraph.anInt447];
		CullingCluster aclass47[] = SceneGraph.aClass47ArrayArray474[SceneGraph.anInt447];
		SceneGraph.anInt475 = 0;
		for (int k = 0; k < j; k++) {
			CullingCluster cullingCluster = aclass47[k];
			if (cullingCluster.searchMask == 1) {
				int l = (cullingCluster.tileStartX - SceneGraph.anInt453) + 25;
				if ((l < 0) || (l > 50)) {
					continue;
				}
				int k1 = (cullingCluster.tileStartY - SceneGraph.anInt454) + 25;
				if (k1 < 0) {
					k1 = 0;
				}
				int j2 = (cullingCluster.tileEndY - SceneGraph.anInt454) + 25;
				if (j2 > 50) {
					j2 = 50;
				}
				boolean flag = false;
				while (k1 <= j2) {
					if (SceneGraph.aBooleanArrayArray492[l][k1++]) {
						flag = true;
						break;
					}
				}
				if (!flag) {
					continue;
				}
				int j3 = SceneGraph.anInt455 - cullingCluster.worldStartX;
				if (j3 > 32) {
					cullingCluster.tileDistance = 1;
				} else {
					if (j3 >= -32) {
						continue;
					}
					cullingCluster.tileDistance = 2;
					j3 = -j3;
				}
				cullingCluster.startYToScreen = (cullingCluster.worldStartY - SceneGraph.anInt457 << 8) / j3;
				cullingCluster.endYToScreen = (cullingCluster.worldEndY - SceneGraph.anInt457 << 8) / j3;
				cullingCluster.startZToScreen = (cullingCluster.worldStartZ - SceneGraph.anInt456 << 8) / j3;
				cullingCluster.endZToScreen = (cullingCluster.worldEndZ - SceneGraph.anInt456 << 8) / j3;
				SceneGraph.aClass47Array476[SceneGraph.anInt475++] = cullingCluster;
				continue;
			}
			if (cullingCluster.searchMask == 2) {
				int i1 = (cullingCluster.tileStartY - SceneGraph.anInt454) + 25;
				if ((i1 < 0) || (i1 > 50)) {
					continue;
				}
				int l1 = (cullingCluster.tileStartX - SceneGraph.anInt453) + 25;
				if (l1 < 0) {
					l1 = 0;
				}
				int k2 = (cullingCluster.tileEndX - SceneGraph.anInt453) + 25;
				if (k2 > 50) {
					k2 = 50;
				}
				boolean flag1 = false;
				while (l1 <= k2) {
					if (SceneGraph.aBooleanArrayArray492[l1++][i1]) {
						flag1 = true;
						break;
					}
				}
				if (!flag1) {
					continue;
				}
				int k3 = SceneGraph.anInt457 - cullingCluster.worldStartY;
				if (k3 > 32) {
					cullingCluster.tileDistance = 3;
				} else {
					if (k3 >= -32) {
						continue;
					}
					cullingCluster.tileDistance = 4;
					k3 = -k3;
				}
				cullingCluster.startXToScreen = (cullingCluster.worldStartX - SceneGraph.anInt455 << 8) / k3;
				cullingCluster.endXToScreen = (cullingCluster.worldEndX - SceneGraph.anInt455 << 8) / k3;
				cullingCluster.startZToScreen = (cullingCluster.worldStartZ - SceneGraph.anInt456 << 8) / k3;
				cullingCluster.endZToScreen = (cullingCluster.worldEndZ - SceneGraph.anInt456 << 8) / k3;
				SceneGraph.aClass47Array476[SceneGraph.anInt475++] = cullingCluster;
			} else if (cullingCluster.searchMask == 4) {
				int j1 = cullingCluster.worldStartZ - SceneGraph.anInt456;
				if (j1 > 128) {
					int i2 = (cullingCluster.tileStartY - SceneGraph.anInt454) + 25;
					if (i2 < 0) {
						i2 = 0;
					}
					int l2 = (cullingCluster.tileEndY - SceneGraph.anInt454) + 25;
					if (l2 > 50) {
						l2 = 50;
					}
					if (i2 <= l2) {
						int i3 = (cullingCluster.tileStartX - SceneGraph.anInt453) + 25;
						if (i3 < 0) {
							i3 = 0;
						}
						int l3 = (cullingCluster.tileEndX - SceneGraph.anInt453) + 25;
						if (l3 > 50) {
							l3 = 50;
						}
						boolean flag2 = false;
						label0: for (int i4 = i3; i4 <= l3; i4++) {
							for (int j4 = i2; j4 <= l2; j4++) {
								if (!SceneGraph.aBooleanArrayArray492[i4][j4]) {
									continue;
								}
								flag2 = true;
								break label0;
							}
						}
						if (flag2) {
							cullingCluster.tileDistance = 5;
							cullingCluster.startXToScreen = (cullingCluster.worldStartX
							- SceneGraph.anInt455 << 8)
							/ j1;
							cullingCluster.endXToScreen = (cullingCluster.worldEndX
							- SceneGraph.anInt455 << 8)
							/ j1;
							cullingCluster.startYToScreen = (cullingCluster.worldStartY
							- SceneGraph.anInt457 << 8)
							/ j1;
							cullingCluster.endYToScreen = (cullingCluster.worldEndY
							- SceneGraph.anInt457 << 8)
							/ j1;
							SceneGraph.aClass47Array476[SceneGraph.anInt475++] = cullingCluster;
						}
					}
				}
			}
		}
	}

	private boolean method320(int i, int j, int k) {
		int l = anIntArrayArrayArray445[i][j][k];
		if (l == -SceneGraph.anInt448) {
			return false;
		}
		if (l == SceneGraph.anInt448) {
			return true;
		}
		int i1 = j << 7;
		int j1 = k << 7;
		if (method324(i1 + 1, anIntArrayArrayArray440[i][j][k], j1 + 1)
		&& method324((i1 + 128) - 1, anIntArrayArrayArray440[i][j + 1][k], j1 + 1)
		&& method324((i1 + 128) - 1, anIntArrayArrayArray440[i][j + 1][k + 1], (j1 + 128) - 1)
		&& method324(i1 + 1, anIntArrayArrayArray440[i][j][k + 1], (j1 + 128) - 1)) {
			anIntArrayArrayArray445[i][j][k] = SceneGraph.anInt448;
			return true;
		} else {
			anIntArrayArrayArray445[i][j][k] = -SceneGraph.anInt448;
			return false;
		}
	}

	private boolean method321(int i, int j, int k, int l) {
		if (!method320(i, j, k)) {
			return false;
		}
		int i1 = j << 7;
		int j1 = k << 7;
		int k1 = anIntArrayArrayArray440[i][j][k] - 1;
		int l1 = k1 - 120;
		int i2 = k1 - 230;
		int j2 = k1 - 238;
		if (l < 16) {
			if (l == 1) {
				if (i1 > SceneGraph.anInt455) {
					if (!method324(i1, k1, j1)) {
						return false;
					}
					if (!method324(i1, k1, j1 + 128)) {
						return false;
					}
				}
				if (i > 0) {
					if (!method324(i1, l1, j1)) {
						return false;
					}
					if (!method324(i1, l1, j1 + 128)) {
						return false;
					}
				}
				return method324(i1, i2, j1) && method324(i1, i2, j1 + 128);
			}
			if (l == 2) {
				if (j1 < SceneGraph.anInt457) {
					if (!method324(i1, k1, j1 + 128)) {
						return false;
					}
					if (!method324(i1 + 128, k1, j1 + 128)) {
						return false;
					}
				}
				if (i > 0) {
					if (!method324(i1, l1, j1 + 128)) {
						return false;
					}
					if (!method324(i1 + 128, l1, j1 + 128)) {
						return false;
					}
				}
				return method324(i1, i2, j1 + 128) && method324(i1 + 128, i2, j1 + 128);
			}
			if (l == 4) {
				if (i1 < SceneGraph.anInt455) {
					if (!method324(i1 + 128, k1, j1)) {
						return false;
					}
					if (!method324(i1 + 128, k1, j1 + 128)) {
						return false;
					}
				}
				if (i > 0) {
					if (!method324(i1 + 128, l1, j1)) {
						return false;
					}
					if (!method324(i1 + 128, l1, j1 + 128)) {
						return false;
					}
				}
				return method324(i1 + 128, i2, j1) && method324(i1 + 128, i2, j1 + 128);
			}
			if (l == 8) {
				if (j1 > SceneGraph.anInt457) {
					if (!method324(i1, k1, j1)) {
						return false;
					}
					if (!method324(i1 + 128, k1, j1)) {
						return false;
					}
				}
				if (i > 0) {
					if (!method324(i1, l1, j1)) {
						return false;
					}
					if (!method324(i1 + 128, l1, j1)) {
						return false;
					}
				}
				return method324(i1, i2, j1) && method324(i1 + 128, i2, j1);
			}
		}
		if (!method324(i1 + 64, j2, j1 + 64)) {
			return false;
		}
		if (l == 16) {
			return method324(i1, i2, j1 + 128);
		}
		if (l == 32) {
			return method324(i1 + 128, i2, j1 + 128);
		}
		if (l == 64) {
			return method324(i1 + 128, i2, j1);
		}
		if (l == 128) {
			return method324(i1, i2, j1);
		} else {
			System.out.println("Warning unsupported wall type");
			return true;
		}
	}

	private boolean method322(int i, int j, int k, int l) {
		if (!method320(i, j, k)) {
			return false;
		}
		int i1 = j << 7;
		int j1 = k << 7;
		return method324(i1 + 1, anIntArrayArrayArray440[i][j][k] - l, j1 + 1)
		&& method324((i1 + 128) - 1, anIntArrayArrayArray440[i][j + 1][k] - l, j1 + 1)
		&& method324((i1 + 128) - 1, anIntArrayArrayArray440[i][j + 1][k + 1] - l, (j1 + 128) - 1)
		&& method324(i1 + 1, anIntArrayArrayArray440[i][j][k + 1] - l, (j1 + 128) - 1);
	}

	private boolean method323(int i, int j, int k, int l, int i1, int j1) {
		if ((j == k) && (l == i1)) {
			if (!method320(i, j, l)) {
				return false;
			}
			int k1 = j << 7;
			int i2 = l << 7;
			return method324(k1 + 1, anIntArrayArrayArray440[i][j][l] - j1, i2 + 1)
			&& method324((k1 + 128) - 1, anIntArrayArrayArray440[i][j + 1][l] - j1, i2 + 1)
			&& method324((k1 + 128) - 1, anIntArrayArrayArray440[i][j + 1][l + 1] - j1,
			(i2 + 128) - 1)
			&& method324(k1 + 1, anIntArrayArrayArray440[i][j][l + 1] - j1, (i2 + 128) - 1);
		}
		for (int l1 = j; l1 <= k; l1++) {
			for (int j2 = l; j2 <= i1; j2++) {
				if (anIntArrayArrayArray445[i][l1][j2] == -SceneGraph.anInt448) {
					return false;
				}
			}
		}
		int k2 = (j << 7) + 1;
		int l2 = (l << 7) + 2;
		int i3 = anIntArrayArrayArray440[i][j][l] - j1;
		if (!method324(k2, i3, l2)) {
			return false;
		}
		int j3 = (k << 7) - 1;
		if (!method324(j3, i3, l2)) {
			return false;
		}
		int k3 = (i1 << 7) - 1;
		return method324(k2, i3, k3) && method324(j3, i3, k3);
	}

	private boolean method324(int i, int j, int k) {
		for (int l = 0; l < SceneGraph.anInt475; l++) {
			CullingCluster cullingCluster = SceneGraph.aClass47Array476[l];
			if (cullingCluster.tileDistance == 1) {
				int i1 = cullingCluster.worldStartX - i;
				if (i1 > 0) {
					int j2 = cullingCluster.worldStartY + (cullingCluster.startYToScreen * i1 >> 8);
					int k3 = cullingCluster.worldEndY + (cullingCluster.endYToScreen * i1 >> 8);
					int l4 = cullingCluster.worldStartZ + (cullingCluster.startZToScreen * i1 >> 8);
					int i6 = cullingCluster.worldEndZ + (cullingCluster.endZToScreen * i1 >> 8);
					if ((k >= j2) && (k <= k3) && (j >= l4) && (j <= i6)) {
						return true;
					}
				}
			} else if (cullingCluster.tileDistance == 2) {
				int j1 = i - cullingCluster.worldStartX;
				if (j1 > 0) {
					int k2 = cullingCluster.worldStartY + (cullingCluster.startYToScreen * j1 >> 8);
					int l3 = cullingCluster.worldEndY + (cullingCluster.endYToScreen * j1 >> 8);
					int i5 = cullingCluster.worldStartZ + (cullingCluster.startZToScreen * j1 >> 8);
					int j6 = cullingCluster.worldEndZ + (cullingCluster.endZToScreen * j1 >> 8);
					if ((k >= k2) && (k <= l3) && (j >= i5) && (j <= j6)) {
						return true;
					}
				}
			} else if (cullingCluster.tileDistance == 3) {
				int k1 = cullingCluster.worldStartY - k;
				if (k1 > 0) {
					int l2 = cullingCluster.worldStartX + (cullingCluster.startXToScreen * k1 >> 8);
					int i4 = cullingCluster.worldEndX + (cullingCluster.endXToScreen * k1 >> 8);
					int j5 = cullingCluster.worldStartZ + (cullingCluster.startZToScreen * k1 >> 8);
					int k6 = cullingCluster.worldEndZ + (cullingCluster.endZToScreen * k1 >> 8);
					if ((i >= l2) && (i <= i4) && (j >= j5) && (j <= k6)) {
						return true;
					}
				}
			} else if (cullingCluster.tileDistance == 4) {
				int l1 = k - cullingCluster.worldStartY;
				if (l1 > 0) {
					int i3 = cullingCluster.worldStartX + (cullingCluster.startXToScreen * l1 >> 8);
					int j4 = cullingCluster.worldEndX + (cullingCluster.endXToScreen * l1 >> 8);
					int k5 = cullingCluster.worldStartZ + (cullingCluster.startZToScreen * l1 >> 8);
					int l6 = cullingCluster.worldEndZ + (cullingCluster.endZToScreen * l1 >> 8);
					if ((i >= i3) && (i <= j4) && (j >= k5) && (j <= l6)) {
						return true;
					}
				}
			} else if (cullingCluster.tileDistance == 5) {
				int i2 = j - cullingCluster.worldStartZ;
				if (i2 > 0) {
					int j3 = cullingCluster.worldStartX + (cullingCluster.startXToScreen * i2 >> 8);
					int k4 = cullingCluster.worldEndX + (cullingCluster.endXToScreen * i2 >> 8);
					int l5 = cullingCluster.worldStartY + (cullingCluster.startYToScreen * i2 >> 8);
					int i7 = cullingCluster.worldEndY + (cullingCluster.endYToScreen * i2 >> 8);
					if ((i >= j3) && (i <= k4) && (k >= l5) && (k <= i7)) {
						return true;
					}
				}
			}
		}
		return false;
	}

	public SceneGraph(int ai[][][]) {
		int i = 104;// was parameter
		int j = 104;// was parameter
		int k = 4;// was parameter
		aBoolean434 = true;
		actions = new InteractiveObject[5000];
		anIntArray486 = new int[10000];
		anIntArray487 = new int[10000];
		anInt437 = k;
		anInt438 = j;
		anInt439 = i;
		groundArray = new Tile[k][j][i];
		anIntArrayArrayArray445 = new int[k][j + 1][i + 1];
		anIntArrayArrayArray440 = ai;
		initToNull();
	}
}
